import { defHttp } from '@/utils/http/axios';
enum Api {
  addAudienceGroupAPI = '/mv/template/createAdvertisementTemplate',
  getAudienceGroupAPI = '/mv/template/pageAdvertisementTemplate',
  getAudiencesListAPI = '/mv/template/listAdvertisementTemplate',
  getPageMatchGeneralTemplateAPI = '/mv/template/pageMatchGeneralTemplate',
  AddCreateMatchGeneralTemplateAPI = '/mv/template/createMatchGeneralTemplate',
  getPageMatchOrientationTemplateAPI = '/mv/template/pageMatchOrientationTemplate',
  AddCreateMatchOrientationTemplateAPI = '/mv/template/createMatchOrientationTemplate',
  getlistMatchOrientationTemplateAPI='/mv/template/listMatchOrientationTemplate'
}

export function addAudienceGroupAPI(params) {
  return defHttp
    .post(
      {
        url: `${Api.addAudienceGroupAPI}`,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}

export function getAudiencesListAPI() {
  return defHttp
    .post(
      {
        url: `${Api.getAudiencesListAPI}`,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
export function getAudienceGroupAPI(params) {
  params['current'] = params.page;
  params['size'] = params.pageSize;
  return defHttp
    .post(
      {
        url: Api.getAudienceGroupAPI,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      const { records, total } = res.data;
      return {
        items: records, // 将数据列表赋值给 items
        total, // 直接使用 total
      };
    })
    .catch((err) => {
    });
}
//普通匹配
export function getPageMatchGeneralTemplateAPI(params) {
  params['current'] = params.page;
  params['size'] = params.pageSize;
  return defHttp
    .post(
      {
        url: Api.getPageMatchGeneralTemplateAPI,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      const { records, total } = res.data;
      return {
        items: records, // 将数据列表赋值给 items
        total, // 直接使用 total
      };
    })
    .catch((err) => {
    });
}

//添加普通普配模板

export function AddCreateMatchGeneralTemplateAPI(params) {
  return defHttp
    .post(
      {
        url: `${Api.AddCreateMatchGeneralTemplateAPI}`,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}

//定向匹配分页模板
export function getPageMatchOrientationTemplateAPI(params) {
  params['current'] = params.page;
  params['size'] = params.pageSize;
  return defHttp
    .post(
      {
        url: Api.getPageMatchOrientationTemplateAPI,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      const { records, total } = res.data;
      return {
        items: records, // 将数据列表赋值给 items
        total, // 直接使用 total
      };
    })
    .catch((err) => {
    });
}

// 定向匹配不分页模板
export function getlistMatchOrientationTemplateAPI() {
  return defHttp
    .post(
      {
        url: Api.getlistMatchOrientationTemplateAPI,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res
    })
}

//添加定向匹配模板
export function AddCreateMatchOrientationTemplateAPI(params) {
  return defHttp
    .post(
      {
        url: `${Api.AddCreateMatchOrientationTemplateAPI}`,
        params,
      },
      {
        isTransformResponse: false,
      },
    )
    .then((res) => {
      return res;
    });
}
